package com.nbjtjc.safe.bean;

import io.swagger.annotations.ApiParam;

import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;

public class Page implements Serializable {
    @ApiParam(value = "每页大小", defaultValue = "10")
    @Transient
    private int pageSize = 10;
    @Transient
    @ApiParam(value = "页号，默认值是1", defaultValue = "1")

    private int pageCurrent = 1;

    @Transient
    @ApiParam("排序的字段名")
    private String sortField;
    @Transient
    @ApiParam("排序规则 desc 默认升序")
    private String sortOrder="desc";

    @Transient
    @ApiParam("开始时间，日期格式")
    private Date startDate;
    @Transient
    @ApiParam("结束时间，日期格式")
    private Date endDate;

    @Transient
    private Integer total=0;

    @Transient
    private Integer pages=0;
    /**
     * 模板导出时的序号
     */
    @Transient
    private Integer num;




    public void countPage(Long total){
        this.total=total.intValue();
        if(total<pageSize){
            this.pages=1;
        }else{
            if(total.intValue()%pageSize==0){
                this.pages=total.intValue()/pageSize;
            }else{
                this.pages=total.intValue()/pageSize+1;
            }
        }
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getPages() {
        return pages;
    }

    public void setPages(Integer pages) {
        this.pages = pages;
    }

    public int getStart(){
        return (pageCurrent-1)*pageSize;
    }
    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageCurrent() {
        return pageCurrent;
    }

    public void setPageCurrent(int pageCurrent) {
        this.pageCurrent = pageCurrent;
    }

    public String getSortField() {
        return sortField;
    }

    public void setSortField(String sortField) {
        this.sortField = sortField;
    }

    public String getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(String sortOrder) {
        this.sortOrder = sortOrder;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }
}
